package com.linkhub.oms.dao.mpservice.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.extension.mapping.config.DeepConfig;
import com.github.yulichang.extension.mapping.relation.Relation;
import com.google.common.collect.Lists;
import com.linkhub.oms.dao.mapper.LocalProductAmountDeclaresInfoEntityMapper;
import com.linkhub.oms.dao.mpservice.ILocalProductAmountDeclaresInfoEntityService;
import com.linkhub.oms.entity.LocalProductAmountDeclaresInfoEntity;
import com.linkhub.oms.entity.LocalProductEntity;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 本地产品申报金额详情表 服务实现类
 * </p>
 *
 * @author Jaycle
 * @version 1.0.0
 * @Description LocalProductAmountDeclaresInfoEntityServiceImpl.java
 * @createTime 2024/06/18 23:52
 */
@Service
public class LocalProductAmountDeclaresInfoEntityServiceImpl extends ServiceImpl<LocalProductAmountDeclaresInfoEntityMapper, LocalProductAmountDeclaresInfoEntity>
        implements ILocalProductAmountDeclaresInfoEntityService {
    @Override
    public void deleteLocalProductAmountDeclaresInfo( String userId, String skuId ) {
        lambdaUpdate()
                .eq(LocalProductAmountDeclaresInfoEntity::getUserId, userId)
                .eq(LocalProductAmountDeclaresInfoEntity::getSkuId, skuId)
                .remove();
    }

    @Override
    public void saveLocalProductAmountDeclaresInfo( List<LocalProductAmountDeclaresInfoEntity> localProductAmountDeclaresInfoEntities ) {
        if (localProductAmountDeclaresInfoEntities != null && !localProductAmountDeclaresInfoEntities.isEmpty()) {
            // Save the entities in batch
            saveBatch(localProductAmountDeclaresInfoEntities);
        }
    }

    @Override
    public List<LocalProductAmountDeclaresInfoEntity> queryAmountDeclaresInfoBySkuId( String userId, String skuId ) {
        return lambdaQuery()
                .eq(LocalProductAmountDeclaresInfoEntity::getUserId, userId)
                .eq(LocalProductAmountDeclaresInfoEntity::getSkuId, skuId)
                .list();
    }

}
